#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <string.h>


int main(int argc, const char *argv[])
{
	int fd[2];
	pipe(fd);

	pid_t pid=fork();

	if(0==pid)
	{
		close(fd[0]);
		char sndmes[32];
		while(1)
		{	
			printf("plz input >>\n");
			fgets(sndmes,32,stdin);
			write(fd[1],sndmes,31);
		}
	}
	else if(pid>0)
	{
		char revmes[32];
		close(fd[1]);
		
		while(0<read(fd[0],revmes,31))
		{
			revmes[strlen(revmes)]=0;
			printf("recv:%s\n",revmes);
		}
	}

	return 0;
}
